<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {#    引入jQuery#}
    <script src="https://cdn.bootcss.com/jquery/3.4.0/jquery.min.js"></script>
    <script src="/front/src/js/index.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"
            integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
            crossorigin="anonymous"></script>
    <title>Title</title>
</head>
<body>
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">租房</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <form class="navbar-form navbar-left" method="get" action="{% url 'house:init_data' %}">
                <div class="form-group">
                    <input type="text" class="form-control" name="p" placeholder="Search">
                </div>
                <button type="submit" class="btn btn-default">获取房源</button>
            </form>

            <ul class="nav navbar-nav navbar-right">
                {% if user.is_authenticated %}
                    <li ><img style="width: 40px;height: 40px" src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1285904007,996698389&fm=26&gp=0.jpg" alt=""></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                           aria-expanded="false">{{ user.username }}<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="#">设置</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="{% url 'house:logout' %}">退出</a></li>
                        </ul>
                    </li>
                {% else %}
                    <li><a href="{% url 'house:map' %}">高德地图</a></li>
                    <li><a  class="btn" data-toggle="modal" data-target="#signup-box">注册</a></li>
                    <li><a  class="btn" data-toggle="modal" data-target="#signin-box">登录</a></li>
                {% endif %}
                <!-- Modal -->
                <form action="{% url 'house:regist' %}" method="post">
                    {% csrf_token %}
                    <div class="modal fade"  id="signup-box" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                        aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="myModalLabel">用户注册</h4>
                            </div>
{#                            注册表单#}
                            <div class="sign-body" style="width:300px;margin:20px auto">
                                <div class="form-group">
                                    <input type="text" class="form-control" name="username"
                                           placeholder="用户名为2到20任意字符">
                                </div>
                                <div class="form-group">
                                    <input type="password" class="form-control" name="pwd1"
                                           placeholder="密码长度不低于6位"
                                           title="密码长度不低于6位">
                                </div>
                                <div class="form-group">
                                    <input type="password" class="form-control" name="pwd2" placeholder="确认密码">
                                </div>
                            </div>
                            <div class="bottom-btn" style="margin: 20px auto;text-align: center">
                                <button type="submit" style="width: 300px" class="btn btn-success btn-lg">注册</button>
                            </div>
                        </div>
                    </div>
                </div>
                </form>

                <form action="{% url 'house:login' %}" method="post">
                    {% csrf_token %}
                    <div class="modal fade" id="signin-box" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                        aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="myModalLabel">用户登录</h4>
                            </div>

                            <div class="sign-body" style="width:300px;margin:20px auto">
                                <div class="form-group">
                                    <input type="text" class="form-control" name="username" placeholder="用户名为2到20任意字符">
                                </div>
                                <div class="form-group">
                                    <input type="password" class="form-control" name="password" placeholder="密码长度不低于6位"
                                           title="密码长度不低于6位">
                                </div>
                            </div>
                            <div class="bottom-btn" style="margin: 20px auto;text-align: center">
                                <button type="submit" style="width: 300px" class="btn btn-success btn-lg">登录</button>
                            </div>
                        </div>
                    </div>
                </div>
                </form>
                {#        <li class="dropdown">#}
                {#          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>#}
                {#          <ul class="dropdown-menu">#}
                {#            <li><a href="#">Action</a></li>#}
                {#            <li><a href="#">Another action</a></li>#}
                {#            <li><a href="#">Something else here</a></li>#}
                {#            <li role="separator" class="divider"></li>#}
                {#            <li><a href="#">Separated link</a></li>#}
                {#          </ul>#}
                {#        </li>#}
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>

</body>
</html>